<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
function doubleClick(selection) {
  resetMouse();
  const target = selection.document.getElementById('target');
  eventSender.mouseMoveTo(
      selection.computeLeft(target) + target.offsetWidth / 2,
      selection.computeTop(target) + target.offsetHeight / 2);
  eventSender.mouseDown();
  eventSender.mouseUp();
  eventSender.mouseDown();
  eventSender.mouseUp();
}

function resetMouse() {
  if (!window.eventSender)
    throw 'This test requires eventSender';
  eventSender.mouseMoveTo(0, 0);
  eventSender.mouseDown();
  eventSender.mouseUp();
}

selection_test(
  [
    '<div contenteditable>',
      '<span contenteditable="false" id="target">AB</span>bd',
    '</div>',
  ],
  selection => doubleClick(selection),
  [
    '<div contenteditable>',
      '<span contenteditable="false" id="target">^AB|</span>bd',
    '</div>',
  ],
  'Select word should not cross editing boundaries.');
</script>
